package com.swsc.solarverse.dao.mapper.forward;

import com.swsc.solarverse.common.mybatis.BasePlusMapper;
import com.swsc.solarverse.dao.entity.forward.ForwardCombinerBoxDataDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author AutoGenerator
 * @since 2022-08-24
 */
@Mapper
public interface ForwardCombinerBoxDataMapper extends BasePlusMapper<ForwardCombinerBoxDataDO> {
    /**
     * 批量插入数据
     * 不存在插入, 存在则更新
     *
     * @param list
     * @return
     */
    @org.apache.ibatis.annotations.Insert(value = {
            "<script>",
            "INSERT INTO solar_forward_combiner_box_data (`id`, `tenant_no`, `organ_no`, `device_id`, `device_name`, `total_voltage`, `i1`, `i2`, `i3`, `i4`, `i5`, `i6`, `i7`, `i8`, `i9`, `i10`, `i11`, `i12`, `i13`, `i14`, `i15`, `i16`, `data_time`, `create_time`) VALUES ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.id}, #{item.tenantNo}, #{item.organNo}, #{item.deviceId}, #{item.deviceName}, #{item.totalVoltage}, #{item.i1}, #{item.i2}, #{item.i3}, #{item.i4}, #{item.i5}, #{item.i6}, #{item.i7}, #{item.i8}, #{item.i9}, #{item.i10}, #{item.i11}, #{item.i12}, #{item.i13}, #{item.i14}, #{item.i15}, #{item.i16}, #{item.dataTime}, #{item.createTime})",
            "</foreach>",
            " ON DUPLICATE KEY UPDATE ",
            "device_name = VALUES (device_name), total_voltage = VALUES (total_voltage), i1 = VALUES (i1), i2 = VALUES (i2), i3 = VALUES (i3), i4 = VALUES (i4),",
            "i5 = VALUES (i5), i6 = VALUES (i6), i7 = VALUES (i7), i8 = VALUES (i8), i9 = VALUES (i9), i10 = VALUES (i10), i11 = VALUES (i11), i12 = VALUES (i12),",
            "i13 = VALUES (i13), i14 = VALUES (i14), i15 = VALUES (i15), i16 = VALUES (i16), ",
            "data_time = VALUES (data_time)",
            "</script>"
    })
    void insertOrUpdateBatch(List<ForwardCombinerBoxDataDO> list);
}
